package service;

import dao.GameDao;
import dao.IGameDao;
import model.Game;

/**
 * Created by VLAD on 09.07.2014.
 */

public class GameService {
    IGameDao gameDao = new GameDao();

    public Game creatGame()
    {
        Game game = new Game();
        gameDao.saveGame(game);
        return game;
    }

    public void setXtogame(Game game, int x, int y)
    {
        byte array[][] = game.getGame();
        array[x][y] = 1;
        updataGame(game);
    }

    public void setOtogame(Game game, int x, int y)
    {
        byte array[][] = game.getGame();
        array[x][y] = 2;
        updataGame(game);
    }

    public Game getGameByID(long id){
        return gameDao.getGameByID(id);
    }

    public void updataGame(Game game){
        gameDao.updateGame(game);
    }

    public void showGame(Game game){
        byte array[][] = game.getGame();
        for(int i = 0; i < array.length; i++)
        {
            for (int j = 0; j < array.length; j++)
            {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
}
